package com.ruoyi.web.util;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.web.dto.TradeDetailQueryResp;
import com.ruoyi.web.entity.TradeDetail;
import org.apache.poi.ss.formula.functions.T;

import java.util.List;

public class PageUtils {
    public static Page getPage() {
        PageDomain pageDomain = TableSupport.buildPageRequest();

        Page<Object> objectPage = new Page<>();
        objectPage.setCurrent(pageDomain.getPageNum());
        objectPage.setSize(pageDomain.getPageSize());

        return objectPage;
    }

    public static TableDataInfo page2Table(Page page){
        TableDataInfo rspData = new TableDataInfo();
        rspData.setTotal(page.getTotal());
        rspData.setRows(page.getRecords());
        return rspData;
    }

    public static <T> Page<T> copyProperties(Page<?> page, List<T> tradeDetailList) {
        Page<T> objectPage = new Page<>();
        BeanUtils.copyProperties(page,objectPage);
        objectPage.setRecords(tradeDetailList);

        return objectPage;
    }
}
